home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 3.2
/
Ham Radio Version 3.2 (Chestnut CD-ROMs)(1993).ISO
/
cw
/
morse2
/
sendmors.src
< prev
Wrap
Text File
|
1989-11-03
|
4KB
|
125 lines
{->>>>SendMorse<<<<---------------------------------------------}
{ }
{ Filename : SENDMORS.SRC -- Last Modified 7/2/88 }
{ }
{ This procedure converts plain text to audible Morse Code at }
{ a specified code speed and tone frequency. The times are }
{ fairly accurate and have been tested on a 4.77 Mhz PC and a }
{ 16 Mhz 80386 machine without significant difference in }
{ code speed. (Turbo's V3.0 DELAY procedure is finally clock }
{ speed independent.) The useful range of the procedure is }
{ from 10 - 35 WPM, with its best "feel" at 15-25 WPM. }
{ }
{ Text is passed to SendMorse as quoted strings of plain }
{ text. If two characters are to be sent as one without an }
{ intermediate delay, an asterisk ('*') must procede the two }
{ characters. This replaces the overbar used in most amateur }
{ literature. }
{ }
{ }
{ }
{---------------------------------------------------------------}
PROCEDURE SendMorse(PlainText : String;
ToneFrequency : Integer;
CodeSpeed : Integer);
VAR
I : Integer;
ToneLength : Integer;
DitLength : Integer;
CodeChar : String;
BlendNextTwo : Boolean;
{ Code is passed to local procedure Morse as literal dots and }
{ dashes: '-.-.' = 'C', and so on. SendMorse converts from }
{ text to the dot/dash code representation. }
PROCEDURE Morse(CodeChar : String);
VAR
I : Integer;
BEGIN
FOR I := 1 TO Length(CodeChar) DO
BEGIN
IF CodeChar[1] IN ['.','-'] THEN
BEGIN
IF CodeChar[I] = '.' THEN ToneLength := DitLength
ELSE Tonelength := DitLength * 3;
Sound(ToneFrequency);
Delay(ToneLength);
NoSound;
Delay(DitLength)
END
END
END;
BEGIN
BlendNextTwo := False;
{ Code speed calculation is derived from formulae published in }
{ the 1986 ARRL Handbook, Section 9-8. I recommend running }
{ this procedure at 10 WPM or greater; 15-20 WPM is its most }
{ effective range. Timer resolution interferes above 35 WPM. }
DitLength := Round((1.2 / CodeSpeed) * 1000.0);
FOR I := 1 TO Length(PlainText) DO IF PlainText[I] = '*' THEN
BlendNextTwo := TRUE ELSE
BEGIN
PlainText[I] := UpCase(PlainText[I]);
CASE PlainText[I] OF
'A' : CodeChar := '.-';
'B' : CodeChar := '-...';
'C' : CodeChar := '-.-.';
'D' : CodeChar := '-..';
'E' : CodeChar := '.';
'F' : CodeChar := '..-.';
'G' : CodeChar := '--.';
'H' : CodeChar := '....';
'I' : CodeChar := '--';
'J' : CodeChar := '.---';
'K' : CodeChar := '-.-';
'L' : CodeChar := '.-..';
'M' : CodeChar := '--';
'N' : CodeChar := '-.';
'O' : CodeChar := '---';
'P' : CodeChar := '.--.';
'Q' : CODECHAR := '--.-';
'R' : CODECHAR := '.-.';
'S' : CODECHAR := '...';
'T' : CODECHAR := '-';
'U' : CODECHAR := '..-';
'V' : CODECHAR := '...-';
'W' : CODECHAR := '.--';
'X' : CODECHAR := '-..-';
'Y' : CODECHAR := '.--.';
'Z' : CODECHAR := '--..';
'1' : CODECHAR := '.----';
'2' : CODECHAR := '..---';
'3' : CODECHAR := '...--';
'4' : CODECHAR := '....-';
'5' : CODECHAR := '.....';
'6' : CODECHAR := '-....';
'7' : CODECHAR := '--...';
'8' : CODECHAR := '---..';
'9' : CODECHAR := '----.';
'0' : CODECHAR := '-----';
'?' : CODECHAR := '..--..';
'.' : CODECHAR := '.-.-.-';
',' : CODECHAR := '--..--';
'/' : CODECHAR := '-..-.';
'$' : CODECHAR := '...-..-';
'-' : CODECHAR := '-....-';
ELSE CODECHAR := ''
END; {CASE}
Morse(CodeChar);
IF NOT BlendNextTwo THEN Delay(Ditlength * 2);
BlendNextTwo := False
END;
END;